class Person

  attr_accessor :age, :sex, :children
  attr_accessor :addiction, :veteran, :hiv_aids # booleans
  
  def initialize(attributes = nil)
    self.children = 0
    self.attributes = attributes
  end
  
  def attributes=(new_attributes)
    return if new_attributes.nil?
    attributes = new_attributes.dup
    attributes.stringify_keys!
    
    attributes.each do |k, v|
      send(k + "=", v)
    end
  end
  
  def age=(age)
    @age = age.to_i
  end
  
  def children=(children)
    @children = children.to_i
  end
  
  def is_valid?
    true
  end
  
  def find_valid_criteria
    criteria = Criteria.find(:all)
    
    criteria.delete_if do |c|
      !eval(c.match)
    end
  end
  
  def find_valid_criteria_ids
    find_valid_criteria.collect { |criteria| criteria.id }
  end
    
end